<?php
namespace app\appin;

use \app\common\AdminController as BaseController;
use \app\common\exception\AdminException;

class Controller extends BaseController
{
	protected $channel = 'web';
	
    /**
     * [initialize 重构自动验证]
     * @return [type] [description]
     */
    public function initialize()
    {
        try {
            $this->initValidatorData([], false, $this->request->param('action'));
			$this->initChannel();
        } catch( \Exception $e ) {
            throw new AdminException($e->getMessage());
        }
    }

    /**
     * [render 模板渲染]
     * @param  string $template [description]
     * @param  array  $data     [description]
     * @return [type]           [description]
     */
    public function render($template = '', $data = [])
    {
        $appin = app()->appin;
        empty($template) && $template = $appin['name'].'/template/'.strtolower($appin['controller']).'/'.$appin['action'];
        return view($template, $data);
    }
	
	/**
	 * 初始化是手机还是PC访问
	 */
	public function initChannel()
	{
		if ( $this->request->isMobile() ) {
			$this->channel = 'wap';
		}
	}
}
